<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
		
		<script>
			"use strict"
			
			async function foo(){
				return new Promise(resolve => {
					setTimeout(resolve, 2000)
				})
			}
			async function test(){
				console.log("开始执行", new Date().toTimeString())
				await foo()
				console.log("执行完毕", new Date().toTimeString())
			}
//			test()
			
			
			
			// async 里await的返回值
			function test2(){
				return "xxx"
			}
			async function asyncPrint(){
				let result = await test2()
				console.log(result)
			}
//			asyncPrint()


			
			async function asyncPrint(){
				let result = await Promise.resolve("成功了...")
				console.log(result)
				result = await Promise.reject("失败了...")
				console.log(result)
			}
			asyncPrint()
		</script>
	</body>
</html>
